<script>
  $(document).ready(function(){
    $("#form1").validate({
		rules: {
			id_assistito: "required",
			id_sostenitore: "required",
			id_tiposostegno: "required"
		},
		messages: {
			id_assistito: "<?php echo __("Scegliere l'assistito", $module) ?>",
			id_sostenitore: "<?php echo __("Scegliere il sostenitore", $module) ?>",
			id_tiposostegno: "<?php echo __("Scegliere il tipo di sostegno", $module) ?>"	
		}
	});
  });
</script>
<h1><?php echo $title; ?></h1>
<div class="noprint">
<?php if (isset($notice) || $notice = $this->session->flashdata('notification')):?>
<p class="notice"><?php echo $notice;?></p>
<?php endif;?>

<div class="adminbox">
<?php 
if($this->user->level['adozioni'] >= LEVEL_EDIT) 
{
    echo anchor('adozioni/anagrafica/adozioni/edit/' . $row['id'], __("Modifica", $module));
    echo " | <a href='http://adozioni.rcj.org/adozioni_wk.php?op=print&id=" . $row['id'] . "'>Stampa scheda</a>";
}
?>
</div>
<form name='form1' id='form1' action="<?php echo site_url('adozioni/anagrafica/adozioni/save') ?>" method="post">

  <table class="form" border="0" cellpadding="1" cellspacing="1">
    <tr>
      <th><strong>Sostenitore</strong></th>
      <td class="item1">
	  <?php if($row['id_sostenitore']): ?>
	  <?php echo $row['sostenitore'] ?>
	  <?php else: ?>
		<select id="id_sostenitore" name="id_sostenitore" class="input-select required chzn-select">
		<option></option>
		<?php foreach($sostenitori as $r): ?>
		<option value="<?php echo $r['id']; ?>" <?php if($r['id'] == $row['id_sostenitore']) echo "selected"; ?>><?php echo $r['nomecognome'] ?></option>
		<?php endforeach; ?>
		</select>
	  <?php endif; ?>
	  
    </tr>
    <tr>
      <th><strong><label for="id_assistito">Assistito</label></strong></th>
      <td class="item1">
	  <?php if($row['id_assistito']): ?>
	  <?php echo $row['assistito'] ?>
	  <?php else: ?>
	  
	<select name="id_assistito" id="id_assistito" class="input-select required chzn-select">
	<option></option>
	<?php foreach($assistiti as $r): ?>
	<option value="<?php echo $r['id']; ?>" <?php if($r['id'] == $row['id_assistito']) echo "selected"; ?>><?php echo $r['nomecognome'] ?></option>
	<?php endforeach; ?>
	</select>
	  <?php endif; ?>
	</td>
    </tr>
    <tr>
      <th><strong>Tipo Sostegno </strong></th>
      <td class="item1">
	  
	<select name="id_tiposostegno" id="id_tiposostegno" class="input-select required">
	<option></option>
	<?php foreach($tiposostegno as $r): ?>
	<option value="<?php echo $r['id']; ?>" <?php if($r['id'] == $row['id_tiposostegno']) echo "selected"; ?>><?php echo $r['nome'] ?></option>
	<?php endforeach; ?>
	</select>
	  
    </tr>
    <tr>
      <th><strong>Stato</strong></th>
      <td class="item1">
	  
	<select name="id_stato" id="id_stato" class="input-select">
	<option></option>
	<?php foreach($stati as $r): ?>
	<option value="<?php echo $r['id']; ?>" <?php if($r['id'] == $row['id_stato']) echo "selected"; ?>><?php echo $r['nome'] ?></option>
	<?php endforeach; ?>
	</select>
	
	</td>
    </tr>
    <tr>
      <th><strong>Data Inizio </strong></th>
      <td class="item1">
      <?php echo $this->ado->select_data('data_inizio', $row['data_inizio'], 'inizio'); ?>
	  </td>
	  
    </tr>
    <tr>
      <th><strong>Data Fine </strong></th>
      <td class="item1">
      <?php echo $this->ado->select_data('data_fine', $row['data_fine'], 'fine'); ?>
	  
	  </td>
    </tr>
    <tr>
      <th><strong>Ultimo Contatto </strong></th>
      <td class="item1">
      <?php echo $this->ado->select_data('ultimo_contatto', $row['ultimo_contatto'], 'contatto'); ?>
	  </td>
    </tr>
    <tr>
      <th><strong>Note</strong></th>
      <td class="item1">
	  <textarea name='note' id='note' class='input-textarea'><?php echo ($row['note']) ?></textarea>
	  </td>
    </tr>
    <tr>
      <th><strong>Totali Anni </strong></th>
      <td class="item1">
	  <textarea name='totali_anni' id='totali_anni' class='input-textarea'><?php echo ($row['totali_anni']) ?></textarea>
	  </td>
    </tr>
  </table>
  <input type='hidden' name='redirect' value="<?php echo $redirect; ?>" />
<input type="submit" value=" <?php echo __("Salva", $module) ?> " class="input-submit" />
<input type="button" onClick="document.location = '<?php echo $redirect ?>'" value=   "<?php echo __("Annulla", $module) ?>" class="input-submit" />
<input type="hidden" name="id" value="<?php echo $row['id'] ?>" />
</form>

